package com.jin.webvideo.config.filter.access.rule;

import com.jin.webvideo.config.filter.access.GlobalStore;
import com.jin.webvideo.config.filter.access.handler.AccessHandler;
import com.jin.webvideo.entity.SessionStore;
import lombok.Data;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

public class OrAccessRule extends MultiAccessRule {
    public OrAccessRule(AccessHandler.AccessRule... rules) {
        super(rules);
    }
    @Override
    public boolean compute(GlobalStore globalStore, SessionStore store, HttpServletRequest request) {
        for (AccessHandler.AccessRule handler : rules) {
            if (handler.compute(globalStore, store, request)) {
                return true;
            }
        }
        return false;
    }
}
